package com.briup.recognition.service.impl;

import com.briup.recognition.bean.GreenhouseMessage;
import com.briup.recognition.bean.GreenhouseMessageExample;
import com.briup.recognition.dao.GreenhouseMessageMapper;
import com.briup.recognition.service.IGreenhouseMessageService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class GreenhouseMessageSerciveImpl implements IGreenhouseMessageService {

    @Resource
    private GreenhouseMessageMapper greenhouseMessageMapper;

    @Override
    public List<GreenhouseMessage> query(){
        GreenhouseMessageExample example = new GreenhouseMessageExample();
        return greenhouseMessageMapper.selectByExample(example);
    }

    @Override
    public void saveOrUpdate(GreenhouseMessage greenhouseMessage){
        if (greenhouseMessage.getId()!=null){
            greenhouseMessageMapper.updateByPrimaryKey(greenhouseMessage);
        }else {
            greenhouseMessageMapper.insert(greenhouseMessage);
        }
    }

    @Override
    public void deleteById(long id) {
        greenhouseMessageMapper.deleteByPrimaryKey(id);
    }


}
